<?php
namespace App\Exports\Bureau;

use App\Models\Bureau\WxBureau;
use App\Models\Bureau\WxBureauGroup;
use App\Models\Bureau\WxClubTeam;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;

class UserInfoFillExport implements WithMultipleSheets
{
    protected $bureau = null;
    public function __construct(WxBureau $bureau) {
        $this->bureau = $bureau;
    }

    public function sheets(): array
    {
        $sheets = [];
        WxBureauGroup::where('bureau_id', $this->bureau->id)->orderBy('id', 'asc')->get()->map(function ($group) use (&$sheets){
            WxClubTeam::where('group_id', $group->id)->orderBy('id', 'asc')->get()->map(function ($team) use (&$sheets){
                $sheets[] = new UserInfoFillExportTeam($team);
            });
        });
        return $sheets;
    }
}